{extend name="layout" /}
{block name="body"}
 <div class="row">
      <div class="col-lg-12">
        <div class="card">
          <div class="card-body">
              <div class="form-group">
				<label for="payapi">第三方支付API接口</label>
				<input type="text" class="form-control" id="payapi" value="{$apppay.payapi}" placeholder="请输入支付API接口......">
              </div>
              <div class="form-group">
                <label for="payid">商户ID</label>
                <input type="text" class="form-control" id="payid" value="{$apppay.payid}" placeholder="请输入商户ID......">
              </div>
              <div class="form-group">
                <label for="paykey">商户秘钥</label>
                <input type="text" class="form-control" id="paykey" value="{$apppay.paykey}" placeholder="请输入商户秘钥......">
              </div>
			  <div class="form-group">
			    <label for="aliid">支付宝支付ID(APP支付)</label>
			    <input type="text" class="form-control" id="aliid" value="{$apppay.aliid}" placeholder="请输入支付宝支付ID......">
			  </div>
			  <div class="form-group">
			  	<label for="aliprivatekey">支付宝私钥</label>
			  	<textarea class="form-control" aria-label="With textarea" id="aliprivatekey" placeholder="请输入支付宝私钥......" style="height: 240px;">{$apppay.aliprivatekey}</textarea>
			  </div>
			  <div class="form-group">
			    <label for="alikey">支付宝公钥</label>
			    <textarea class="form-control" aria-label="With textarea" id="alikey" placeholder="请输入支付宝公钥......" style="height: 240px;">{$apppay.alikey}</textarea>
			  </div>
			  <div class="form-group">
			    <label for="paynotify">异步通知</label>
			    <input type="text" class="form-control" id="paynotify" value="{$apppay.paynotify}" placeholder="请输入异步通知地址.......">
			  </div>
              <button type="button" onclick="updateapppay()" class="btn btn-w-sm btn-primary mb-2">提交</button>
              <button type="button" class="btn btn-default mb-2" onclick="javascript:history.back(-1);return false;">返 回
              </button>
            </form>
          </div>
        </div>
      </div>
    </div>
{/block} {block name="js"}
<script type="text/javascript">
	function updateapppay() {
	    var l = $('body').lyearloading({
	        opacity: 0.2,
	        spinnerSize: 'lg',
	        spinnerText: '后台处理中，请稍后...',
	        textColorClass: 'text-info',
	        spinnerColorClass: 'text-info'
	    });
		var payapi = $.trim($("#payapi").val());
		var payid = $.trim($("#payid").val());
		var paykey = $.trim($("#paykey").val());
		var aliid = $.trim($("#aliid").val());
		var aliprivatekey = $.trim($("#aliprivatekey").val());
		var alikey = $.trim($("#alikey").val());
		var paynotify = $.trim($("#paynotify").val());
	    $.ajax({
	        type: "POST",
	        url: "{:url('app/apppay')}",
	        data: {
	          payapi:payapi,
	          payid:payid,
	          paykey:paykey,
	          aliid:aliid,
	          aliprivatekey:aliprivatekey,
	          alikey:alikey,
	          paynotify:paynotify
	        },
	        dataType: "json",
	        success: function (data) {
	            setTimeout(function () {
	                l.destroy();
	            }, 1e3)
	            if (data.code == 1) {
	                notify.success(data.msg);
	            } else {
	                notify.error(data.msg);
	            }
	        },
	        error: function () {
	            l.destroy();
	            notify.error("系统错误");
	        }
	    })
	}
</script>
{/block}